import {channelAction} from '../action/channels'
import {Channel} from '../../stroe/index'
// 初始化频道的类型
export type initChannel={
    activeID:number,
    channelList:Channel[]
}
// 初始化频道的数据
let initState={
    activeID:0,
    channelList:[]
}
export default function channels(state:initChannel=initState,action:channelAction) {
    console.log(action)
    if(action.type==="GET_CHANNEL") {
        // console.log('保存数据channelList');
        return {...state, channelList:action.data}
    } else if(action.type==="CHANGE_ID") {
        // console.log('改变id状态'+action.id);
        return {...state,activeID:action.id}
    }
    return state
}

